import React, { Component } from 'react'
import fetch from '@/utils/request'

export default class index extends Component {
  // 微信支付
  jsApiCall = (payJson) => {
    // eslint-disable-next-line no-undef
    console.log("payJson:", payJson)
    WeixinJSBridge.invoke(
      'getBrandWCPayRequest', {
      appId: payJson.appId,
      nonceStr: payJson.nonceStr,
      package: payJson.package,
      signType: payJson.signType,
      timeStamp: payJson.timeStamp,
      paySign: payJson.paySign,
    },
      (res) => {
        console.log('支付页面：', res)
        if (res.err_msg === 'get_brand_wcpay_request:ok') {
          // eslint-disable-next-line no-undef
          WeixinJSBridge.log(res.err_msg);
          // if (orderType === 1) {
          //   window.location.href = `/cicp/platform/buy/regimentType?orderSn=${orderInfo.regiment_sn}&orderType=${orderType}`
          // } else if (orderType === 2) {
          //   window.location.href = `/cicp/platform/buy/regimentType?goodId=${goodId}&orderType=${orderType}`
          // }
        } else {
          // this.Message.show({
          //   msg: '支付失败',
          //   clickClose: true, // 点击蒙层可关闭
          //   btn: ['确认'],
          //   onConfirm: () => {
          //     // window.history.go(-1)
          //   },
          // })
        }
      },
    )
  }
  render() {
    return (
      <div>
        <h1>404</h1>
      </div>
    )
  }

  componentDidMount() {
    fetch.get('/api/order/payOrder?order_id=76').then(res => {
      console.log('res:', res)
      this.jsApiCall(res)
    })
  }
}
